package com.gisocn.onemap.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import com.gisocn.onemap.interfaces.OnItemClickListener;
import com.gisocn.onemap.interfaces.OnItemDeleteListener;
import com.gisocn.onemap.model.QueryFeature;
import com.gisocn.onemap.sgzx.R;
import com.google.gson.JsonObject;
import java.util.ArrayList;

/* loaded from: classes2.dex */
public class QueryStatisticsAdapter extends RecyclerView.Adapter<ViewHolder> {
    private Context context;
    private String displayField;
    private ArrayList<JsonObject> list;
    private QueryFeature queryFeature;
    private String subTitleField;
    private int index = 0;
    private OnItemClickListener onItemClickListener = null;
    private OnItemDeleteListener onItemDeleteListener = null;

    /* loaded from: classes2.dex */
    public class ViewHolder_ViewBinding implements Unbinder {
        private ViewHolder target;

        public ViewHolder_ViewBinding(ViewHolder viewHolder, View view) {
            this.target = viewHolder;
            viewHolder.ivDel = (ImageView) Utils.findRequiredViewAsType(view, R.id.iv_del, "field 'ivDel'", ImageView.class);
            viewHolder.tvTitle = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_title, "field 'tvTitle'", TextView.class);
            viewHolder.tvTag = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_tag, "field 'tvTag'", TextView.class);
            viewHolder.tvDel = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_del, "field 'tvDel'", TextView.class);
            viewHolder.llContent = (LinearLayout) Utils.findRequiredViewAsType(view, R.id.ll_content, "field 'llContent'", LinearLayout.class);
        }

        @Override // butterknife.Unbinder
        public void unbind() {
            ViewHolder viewHolder = this.target;
            if (viewHolder == null) {
                throw new IllegalStateException("Bindings already cleared.");
            }
            this.target = null;
            viewHolder.ivDel = null;
            viewHolder.tvTitle = null;
            viewHolder.tvTag = null;
            viewHolder.tvDel = null;
            viewHolder.llContent = null;
        }
    }

    public QueryStatisticsAdapter(Context context, QueryFeature queryFeature) {
        this.context = context;
        this.queryFeature = queryFeature;
    }

    public QueryStatisticsAdapter(Context context, ArrayList<JsonObject> arrayList) {
        this.context = context;
        this.list = arrayList;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public void setOnItemDeleteListener(OnItemDeleteListener onItemDeleteListener) {
        this.onItemDeleteListener = onItemDeleteListener;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_querystatistics, viewGroup, false));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
        if (i == this.index) {
            viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(this.context, R.color.colorGray));
            viewHolder.tvTag.setVisibility(0);
        } else {
            viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(this.context, R.color.colorWhite));
            viewHolder.tvTag.setVisibility(4);
        }
        if (this.list.get(i).get("displayField") != null) {
            if (this.list.get(i).get(this.list.get(i).get("displayField").getAsString().toUpperCase()) != null) {
                TextView textView = viewHolder.tvTitle;
                textView.setText((i + 1) + "." + this.list.get(i).get(this.list.get(i).get("displayField").getAsString().toUpperCase()).getAsString());
            } else {
                TextView textView2 = viewHolder.tvTitle;
                textView2.setText((i + 1) + "." + this.list.get(i).get(this.list.get(i).get("displayField").getAsString()).getAsString());
            }
        } else {
            TextView textView3 = viewHolder.tvTitle;
            textView3.setText((i + 1) + ".");
        }
        if (this.list.get(i).get("subTitleField") != null) {
            if (this.list.get(i).get(this.list.get(i).get("subTitleField").getAsString().toUpperCase()) != null) {
                viewHolder.tvTag.setText(this.list.get(i).get(this.list.get(i).get("subTitleField").getAsString().toUpperCase()).getAsString());
            }
        }
        viewHolder.ivDel.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.QueryStatisticsAdapter.1
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                viewHolder.tvDel.setVisibility(0);
            }
        });
        viewHolder.tvDel.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.QueryStatisticsAdapter.2
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (QueryStatisticsAdapter.this.onItemDeleteListener != null) {
                    QueryStatisticsAdapter.this.onItemDeleteListener.onItemDelete(view, i);
                }
            }
        });
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.QueryStatisticsAdapter.3
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                QueryStatisticsAdapter.this.index = i;
                QueryStatisticsAdapter.this.notifyDataSetChanged();
                viewHolder.tvDel.setVisibility(8);
                if (QueryStatisticsAdapter.this.onItemClickListener != null) {
                    QueryStatisticsAdapter.this.onItemClickListener.onItemClick(view, i);
                }
            }
        });
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemCount() {
        return this.list.size();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes2.dex */
    public static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_del)
        ImageView ivDel;
        @BindView(R.id.ll_content)
        LinearLayout llContent;
        @BindView(R.id.tv_del)
        TextView tvDel;
        @BindView(R.id.tv_tag)
        TextView tvTag;
        @BindView(R.id.tv_title)
        TextView tvTitle;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
